// 线程状态
public class ThreadDemo10 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("hello t");
        });


        System.out.println("线程启动之前的状态: " + t.getState());
        // NEW
        // 安排了工作, 还未开执行

        t.start();

        System.out.println("就绪状态: " + t.getState());
        // RUNNABLE 分为正在CPU上执行, 和准备上CPU执行

        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("等待状态: " + t.getState());
        // TIMED_WAITING
        // BLOCKED
        // WAITING

        t.join();

        System.out.println("结束状态: " + t.getState());
        // TERMINATED
    }

    public static void main1(String[] args) {
        for (Thread.State state : Thread.State.values()) {
            System.out.println(state);
        }
    }
}
